/*
* Author: honrun
*/
#ifndef DEVICESUART_H_
#define DEVICESUART_H_


#define UART_LOG  USART1
#define UART_WIFI USART1
#define UART_BUS  USART2
#define UART_LORA UART3


#define USART1_DMA_READ_LENGTH  (128)
#define USART1_DMA_SEND_LENGTH  (0)
#define USART2_DMA_READ_LENGTH  (128)
#define USART2_DMA_SEND_LENGTH  (0)
#define USART3_DMA_READ_LENGTH  (128)
#define USART3_DMA_SEND_LENGTH  (0)



extern uint8_t g_USART1ReadDMABuff[USART1_DMA_READ_LENGTH];
extern uint8_t g_USART2ReadDMABuff[USART2_DMA_READ_LENGTH];
extern uint8_t g_USART3ReadDMABuff[USART3_DMA_READ_LENGTH];



void vUart1Init(void);
void vUart2Init(void);
void vUart3Init(void);


void vUart1DMAInit(void);
void vUart2DMAInit(void);
void vUart3DMAInit(void);

void vUartBaudrateSet(USART_TypeDef *USARTx, int32_t iBaudrate);

void vUartSendDatas(USART_TypeDef *USARTx, void *pvDatas, int32_t iLength);
void vUartSendStrings(USART_TypeDef *USARTx, char *pcStrings);

void vUartDMASendDatas(USART_TypeDef *USARTx, void *pvDatas, int32_t iLength);
void vUartDMASendStrings(USART_TypeDef *USARTx, char *pcStrings);

int8_t cUartReceiveByte(USART_TypeDef *USARTx, uint8_t *pucByte);
int8_t cUartReceiveDatas(USART_TypeDef *USARTx, void *pvDatas, int32_t iLength);
int32_t iUartReceiveAllDatas(USART_TypeDef *USARTx, void *pvDatas, int32_t iLengthLimit);
int32_t iUartReceiveLengthGet(USART_TypeDef *USARTx);
int8_t cUartReceiveClear(USART_TypeDef *USARTx);


#endif /* DEVICESUART_H_ */
